//-
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

include /app/helpers/jade/mixins

-var form = 'general'
-var model = '$ctrl.clonedCluster'
-var modelDiscoveryKind = model + '.discovery.kind'

include ./general/discovery/cloud
include ./general/discovery/google
include ./general/discovery/jdbc
include ./general/discovery/multicast
include ./general/discovery/s3
include ./general/discovery/shared
include ./general/discovery/vm
include ./general/discovery/zookeeper
include ./general/discovery/kubernetes

panel-collapsible(opened=`::true` ng-form=form)
    panel-title General
    panel-description
        | Common cluster configuration.
        | #[a.link-success(href="https://apacheignite.readme.io/docs/clustering" target="_blank") More info]
    panel-content.pca-form-row
        .pca-form-column-6.pc-form-grid-row
            .pc-form-grid-col-30
                +form-field__text({
                    label: 'Name:',
                    model: `${model}.name`,
                    name: '"clusterName"',
                    placeholder: 'Input name',
                    required: true,
                    tip: 'Instance name allows to indicate to what grid this particular grid instance belongs to'
                })(
                    ignite-unique='$ctrl.shortClusters'
                    ignite-unique-property='name'
                    ignite-unique-skip=`["_id", ${model}]`
                )
                    +form-field__error({ error: 'igniteUnique', message: 'Cluster name should be unique.' })

            .pc-form-grid-col-30
                +form-field__ip-address({
                    label: 'Local host:',
                    model: `${model}.localHost`,
                    name: '"localHost"',
                    enabled: 'true',
                    placeholder: '0.0.0.0',
                    tip: 'System-wide local address or host for all Ignite components to bind to<br/>\
                          If not defined then Ignite tries to use local wildcard address<br/>\
                          That means that all services will be available on all network interfaces of the host machine'
                })

            .pc-form-grid-col-60
                +form-field__dropdown({
                    label: 'Discovery:',
                    model: `${model}.discovery.kind`,
                    name: '"discovery"',
                    placeholder: 'Choose discovery',
                    options: '$ctrl.Clusters.discoveries',
                    tip: 'Discovery allows to discover remote nodes in grid\
                        <ul>\
                            <li>Static IPs - IP Finder which works only with pre configured list of IP addresses specified</li>\
                            <li>Multicast - Multicast based IP finder</li>\
                            <li>AWS S3 - AWS S3 based IP finder that automatically discover cluster nodes on Amazon EC2 cloud</li>\
                            <li>Apache jclouds - Apache jclouds multi cloud toolkit based IP finder for cloud platforms with unstable IP addresses</li>\
                            <li>Google cloud storage - Google Cloud Storage based IP finder that automatically discover cluster nodes on Google Compute Engine cluster</li>\
                            <li>JDBC - JDBC based IP finder that use database to store node IP address</li>\
                            <li>Shared filesystem - Shared filesystem based IP finder that use file to store node IP address</li>\
                            <li>Apache ZooKeeper - Apache ZooKeeper based IP finder when you use ZooKeeper to coordinate your distributed environment</li>\
                            <li>Kubernetes - IP finder for automatic lookup of Ignite nodes running in Kubernetes environment</li>\
                        </ul>'
                })
            .pc-form-group
                +discovery-cloud()(ng-if=`${modelDiscoveryKind} === 'Cloud'`)
                +discovery-google()(ng-if=`${modelDiscoveryKind} === 'GoogleStorage'`)
                +discovery-jdbc()(ng-if=`${modelDiscoveryKind} === 'Jdbc'`)
                +discovery-multicast()(ng-if=`${modelDiscoveryKind} === 'Multicast'`)
                +discovery-s3()(ng-if=`${modelDiscoveryKind} === 'S3'`)
                +discovery-shared()(ng-if=`${modelDiscoveryKind} === 'SharedFs'`)
                +discovery-vm()(ng-if=`${modelDiscoveryKind} === 'Vm'`)
                +discovery-zookeeper()(ng-if=`${modelDiscoveryKind} === 'ZooKeeper'`)
                +discovery-kubernetes()(ng-if=`${modelDiscoveryKind} === 'Kubernetes'`)

        .pca-form-column-6
            -var model = '$ctrl.clonedCluster'
            +preview-xml-java(model, 'clusterGeneral')
